# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class BiliItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    user_id = scrapy.Field()
    username = scrapy.Field()
    sex = scrapy.Field()
    sign = scrapy.Field()
    levels = scrapy.Field()
    following = scrapy.Field()
    follower = scrapy.Field()

    def save_to_mysql(self):
        sql = 'insert into bilibi_app(user_id,username,sex,sign,levels,following,follower)' \
              'values (%s,%s,%s,%s,%s,%s,%s)'

        data = (self['user_id'],self['username'],self['sex'],self['sign'],self['levels'],self['following'],self['follower'])

        return sql,data

